<template>
	<view>
		<view v-if="dataList && dataList.length >0">
		<view class="list_one" v-for="(item,index) in dataList">
			<view class="inner flex">
				<view class="list_def" @click="select(index)">
					<image class="list_def_img" src="@/pages/shop/static/image/shop/def.png" v-if="item.nomal==1"></image>
				</view>
				<view class="left" @click="select(index)">
					<view class="list_nav">
						<text class="list_name">{{'收货人：' + item.name}}</text>
						<text class="list_phone">{{item.mobile}}</text>
					</view>
					<text class="list_content">{{'收货地址：' +
						item.province+','+item.city+','+item.area+','+item.address}}</text>
				</view>
				<view class="right" @click="EditPage(item.id)">
					<image class="list_icon" src="@/pages/shop/static/image/shop/edit.png"></image>
				</view>
			</view>
		</view>
		<view style="height: 80px;"></view>
		</view>
		
		<view v-else>
		<nodata wenben="暂无任何地址数据"></nodata>	
		</view>


		<text class="btn btn_add" @click="addad">添加新地址</text>


	</view>
</template>

<script>
	import $util from "@/util/util.js"
	import {openwin} from "@/util/tool.js"
	import nodata from "@/components/nodata/nodata.nvue"
	export default {
		data() {
			return {
			dataList:[]
			}
		},
		components: {
		nodata
		},
		computed: {

		},
		onShow() {
		this.get_data();
		},
		onLoad() {
			
		},
		created() {

		},
		methods: {
			get_data() {
				let that = this;
				$util.showProgress();
				$util.ajax({
					url: 'Shop/ajax_address',
				}, (res, err) => {
					$util.hideProgress();
					if(res.code == 1){
					this.dataList = res.data
					}
					console.log(JSON.stringify(res))
					console.log(JSON.stringify(err))
				})
			},
			addad(){
			openwin('../addressadd/addressadd');	
			},
			EditPage(ids){
			openwin('../addressadd/addressadd?ids='+ids);
			},
			select(i){
			var data = this.dataList[i];
			$util.sendEvent('select_addess',data);
			$util.toast('选择成功');
			setTimeout(()=>{
			uni.navigateBack()	
			},500)
			}
		}
	}
</script>

<style scoped>
	.list_one {
		margin: 15px 15px 0;
		box-shadow: 0 0 10px #ddd;
		position: relative;
	}

	.delete {
		background-color: #d8d8d8;
		color: #ffffff;
		width: 50px;
		line-height: 30px;
		text-align: center;
		margin-left: 15px;
	}

	.inner {
		flex-direction: row;
		align-items: center;
		border-radius: 4px;
		height: 106px;
		background-color: white;
	}

	.left {
		flex: 1;
		margin-left: 15px;
	}

	.right {
		justify-content: center;
		padding: 10px 15px;
	}

	.list_icon {
		width: 18px;
		height: 18px;
	}

	.list_def {
		width: 37px;
		height: 37px;
		position: absolute;
		top: 0;
		right: 0;
	}

	.list_def_img {
		width: 100%;
		height: 100%;
	}

	.list_nav {
		flex-direction: row;
		justify-content: space-between;
	}

	.list_name {
		font-size: 15px;
		color: #333333;
	}

	.list_phone {
		font-size: 14px;
		color: #777777;
	}

	.list_content {
		height: 50px;
		line-height: 20px;
		font-size: 12px;
		margin-top: 5px;
		color: #333333;
	}

	.btn_add {
		align-self: stretch;
		height: 45px;
		border-radius: 4px;
		text-align: center;
		line-height: 45px;
		color: white;
		background-color: #FF7037;
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
	}

	.btn_add:active {
		opacity: 0.7;
	}
</style>
